package com.ruoyi.web.controller.seed;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SeedConsumeTemporary;
import com.ruoyi.system.service.ISeedConsumeTemporaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 种子临时领用信息Controller
 *
 * @author ruoyi
 * @date 2021-07-08
 */
@RestController
@RequestMapping("/seed/temporary")
public class SeedConsumeTemporaryController extends BaseController
{
    @Autowired
    private ISeedConsumeTemporaryService seedConsumeTemporaryService;

    /**
     * 查询种子临时领用信息列表
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:list')")
    @GetMapping("/list")
    public TableDataInfo list(SeedConsumeTemporary seedConsumeTemporary)
    {
        startPage();
        List<SeedConsumeTemporary> list = seedConsumeTemporaryService.selectSeedConsumeTemporaryList(seedConsumeTemporary);
        return getDataTable(list);
    }

    /**
     * 导出种子临时领用信息列表
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:export')")
    @Log(title = "种子临时领用信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SeedConsumeTemporary seedConsumeTemporary)
    {
        List<SeedConsumeTemporary> list = seedConsumeTemporaryService.selectSeedConsumeTemporaryList(seedConsumeTemporary);
        ExcelUtil<SeedConsumeTemporary> util = new ExcelUtil<SeedConsumeTemporary>(SeedConsumeTemporary.class);
        return util.exportExcel(list, "种子临时领用信息数据");
    }

    /**
     * 获取种子临时领用信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:query')")
    @GetMapping(value = "/{seedConsumeTemporaryId}")
    public AjaxResult getInfo(@PathVariable("seedConsumeTemporaryId") Long seedConsumeTemporaryId)
    {
        return AjaxResult.success(seedConsumeTemporaryService.selectSeedConsumeTemporaryById(seedConsumeTemporaryId));
    }

    /**
     * 新增种子临时领用信息
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:add')")
    @Log(title = "种子临时领用信息", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody SeedConsumeTemporary seedConsumeTemporary)
    {
        return toAjax(seedConsumeTemporaryService.insertSeedConsumeTemporary(seedConsumeTemporary));
    }

    /**
     * 修改种子临时领用信息
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:edit')")
    @Log(title = "种子临时领用信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody SeedConsumeTemporary seedConsumeTemporary)
    {
        return toAjax(seedConsumeTemporaryService.updateSeedConsumeTemporary(seedConsumeTemporary));
    }

    /**
     * 删除种子临时领用信息
     */
    @PreAuthorize("@ss.hasPermi('seed:temporary:remove')")
    @Log(title = "种子临时领用信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{seedConsumeTemporaryIds}")
    public AjaxResult remove(@PathVariable Long[] seedConsumeTemporaryIds)
    {
        return toAjax(seedConsumeTemporaryService.deleteSeedConsumeTemporaryByIds(seedConsumeTemporaryIds));
    }
}
